<?php

(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/

//if ( !is_superadmin() && !check_purview('manage_link') ) prompt('对不起，你没有权限执行本操作！');

empty($do) && $do = 'list';

$message = array(
	1 => '成功更新分类设置。',
	2 => '成功删除分类设置。',
);

if ($do == 'list') {
	$otype=$_GET[otype];
	if($otype=='1'){
	get_config_keytable("istration_conference_type_sce");
	}elseif($otype=='2'){
	get_config_keytable("istration_conference_type_type");
	}elseif($otype>='9' && $otype<='19'){
	get_config_keytable("office_type_r");
	}else{
	}
	
	
	
	$result = array();
	$sql = "SELECT * FROM ".DB_TABLEPRE."office_type where otype='".$otype."' ORDER BY oid asc";
	$query = $db->query($sql);
	while ($row = $db->fetch_array($query)) {
		//$row['count'] = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."office_type WHERE oid = '$row[oid]'");
		$result[] = $row;
	}
	include_once('template/type.php');

} elseif ($do == 'update') {
	$otype=$_GET[otype];
	$officetype = array();
	$officetype['oname'] = check_str(getGP('newname','P'));
	$officetype['otype'] = $otype;
	$officetype['uid'] = $_USER->id;
	$officetype['odate'] = get_date('Y-m-d H:i:s',PHP_TIME);
	if (!empty($officetype['oname'])) {
		insert_db('office_type', $officetype);
	}
	$oname = getGP('name','P','array');
	foreach ($oname as $key => $val) {
		$key = (int)$key;
		$db->query("UPDATE ".DB_TABLEPRE."office_type SET oname = '$val' WHERE oid = '$key'");
	}
	goto_page('admin.php?ac=type&fileurl=office&otype='.$otype.'&message=1&muid='.$_GET["muid"].'&numberid='.$_GET[numberid].'');

} elseif ($do == 'delete') {
    $otype=$_GET[otype];
	$id = getGP('id','G','int');
	$db->query("DELETE FROM ".DB_TABLEPRE."office_type WHERE oid = '$id'");
	goto_page('admin.php?ac=type&fileurl=office&otype='.$otype.'&message=2&muid='.$_GET["muid"].'&numberid='.$_GET[numberid].'');
}

?>